<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:s="http://sduept.security.el/func"
	template="/template/template_dialog.xhtml">
	<ui:define name="head">
		<title>典型问题库</title>
		<style type="text/css">
			.ui-datatable-scrollable-header-box {
				margin-left: 0px;
				margin-right: 15px !important;
			}
		</style>
		<!-- 
使用方法
在页面中
<p:commandButton value="选择问题" icon="ui-icon-extlink" actionListener="#{自己的Controller.chooseQuestion()}">
	<p:ajax event="dialogReturn"  listener="#{自己的Controller.onSelectorChosen}"  />
</p:commandButton>
在自己的业务controller中 添加如下方法
public void chooseQuestion() {
        Map<String,Object> options = new HashMap<String, Object>();
        options.put("resizable", true);
        options.put("draggable", true);
        options.put("modal", true);
        options.put("reflow", true);//堆叠
       // options.put("width", 1000);
        options.put("height", 700);
        options.put("contentWidth", 1000);
        options.put("contentHeight", 800);
        Map<String,List<String>> params = new HashMap<>();
        RequestContext.getCurrentInstance().openDialog("/ui/common/problembase_selector_single.xhtml", options, params);
    }
	public void onSelectorChosen(SelectEvent event) {
		//返回的是选择的对象
		ProblemBase  pb = (ProblemBase ) event.getObject();
	}
 -->
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<!-- <ui:include src="problemBaseDialog.xhtml" /> -->
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<div class="box-header" id="queryDiv">
					<p:outputLabel value="创建时间：" style="margin-left:5px;" />
					<p:calendar id="popup1" navigator="true" size="15"
						value="#{problemBaseSelectorControlller.queryDateStart}"
						pattern="yyyy-MM-dd" maxdate="Date()" />
					<p:outputLabel for="popup2" value="至 "
						style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="popup2" navigator="true" size="15"
						value="#{problemBaseSelectorControlller.queryDateEnd}"
						pattern="yyyy-MM-dd" maxdate="Date()">
					</p:calendar>
					<p:commandButton value="查询"
						actionListener="#{problemBaseSelectorControlller.query}"
						oncomplete="closeSelectDiv();" update="form:dataTb"
						icon="ui-icon-search" style="margin-left:5px;">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置"
						oncomplete="closeSelectDiv();"
						actionListener="#{problemBaseSelectorControlller.resetQuery}"
						style="margin-left:5px;"
						update="popup1 popup2  :form:dataTb creater problemClass description source dangerLevel reasonClass" />
					<p:commandButton value="确定" update="selectedJson"
						style="margin-left:5px;" icon="ui-icon-plus"
						oncomplete="closeAndSave();"
						actionListener="#{problemBaseSelectorControlller.setDesc}" />
					<h:inputHidden id="selectedJson"
						value="#{problemBaseSelectorControlller.selectedDesc}" />
					<div class="box-tools pull-right">
						<button type="button" id="selectButton" title="高级查询"
							class="btn btn-default" onclick="onSelectDivClick();"
							style="margin-right: 50px;">
							<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
						</button>
					</div>
				</div>
				<div class="panel-collapse collapse" id="selectDiv">
					<div style="margin-top: 10px; margin-bottom: 5px;">
						<p:outputLabel value="创建人员：" style="margin-left:15px;" />
						<p:autoComplete dropdown="true" scrollHeight="400" id="creater"
							value="#{problemBaseSelectorControlller.expertId}" var="expert"
							itemLabel="#{expert.name}" itemValue="#{expert.id}"
							completeMethod="#{expertController.completeExpert}">
						</p:autoComplete>

						<p:outputLabel value="问题分类：" style="margin-left:15px;" />
						<p:autoComplete
							value="#{problemBaseSelectorControlller.queryProblem.problemClass}"
							id="problemClass"
							completeMethod="#{knowledgeBaseController.completeHiddenDangerQuesClass}"
							scrollHeight="400" dropdown="true" />

						<p:outputLabel value="问题描述：" style="margin-left:15px;" />
						<p:inputText
							value="#{problemBaseSelectorControlller.queryProblem.problemDescription}"
							id="description" />
					</div>
					<div style="margin-top: 5px; margin-bottom: 5px;">
						<p:outputLabel value="问题来源：" style="margin-left:15px;" />
						<p:autoComplete
							value="#{problemBaseSelectorControlller.queryProblem.problemSources}"
							id="source"
							completeMethod="#{knowledgeBaseController.completeHiddenDangerSources}"
							scrollHeight="400" dropdown="true" />

						<p:outputLabel value="严重等级：" style="margin-left:15px;" />
						<p:autoComplete
							value="#{problemBaseSelectorControlller.queryProblem.problemDangerLevel}"
							id="dangerLevel"
							completeMethod="#{knowledgeBaseController.completeHiddenDangerGrade}"
							scrollHeight="400" dropdown="true" />

						<p:outputLabel value="原因分类：" style="margin-left:15px;" />
						<p:autoComplete
							value="#{problemBaseSelectorControlller.queryProblem.problemReasonClass}"
							id="reasonClass"
							completeMethod="#{knowledgeBaseController.completeHiddenDangerReasonClass}"
							scrollHeight="400" dropdown="true" />
					</div>
				</div>

			</h:form>
		</div><!-- headDiv结束标签 -->
		
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:growl id="msgs" showDetail="true" />
				<p:dataTable id="dataTb" var="item" emptyMessage="无记录"
					rowIndexVar="ite" lazy="true"
					value="#{problemBaseSelectorControlller.problems}"
					rowKey="#{item.id}" rows="20" paginator="true"
					selection="#{problemBaseSelectorControlller.selected}"
					paginatorTemplate="{left} {RowsPerPageDropdown} {right} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Customer}"
					rowsPerPageTemplate="20,30,50" paginatorPosition="bottom"
					scrollable="true">
					<p:ajax event="rowSelectRadio"
						listener="#{problemBaseSelectorControlller.onRowSelected}" />
					<f:facet name="{Customer}">
						<p:outputLabel
							value="总计：#{problemBaseSelectorControlller.problems.size()}条纪录"
							style="margin-left:20px" />
					</f:facet>
					<f:facet name="{left}">
						<p:outputLabel value="每页显示" />
					</f:facet>
					<f:facet name="{right}">
						<p:outputLabel value="条" style="margin-right:20px" />
					</f:facet>
					<p:column selectionMode="single" style="text-align:center;"
						width="2" />
					<p:column headerText="序号" style="text-align:center;" width="4">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="问题描述" width="38">
						<h:outputText value="#{item.problemDescription}" />
					</p:column>
					<p:column headerText="问题分类" style="text-align:center;" width="10">
						<h:outputText value="#{item.problemClass}" />
					</p:column>
					<p:column headerText="原因" style="text-align:center;" width="10">
						<h:outputText value="#{item.problemReasonClass}" />
					</p:column>
					<p:column headerText="严重等级" style="text-align:center;" width="8">
						<h:outputText value="#{item.problemDangerLevel}" />
					</p:column>
					<p:column headerText="问题来源" style="text-align:center;" width="8">
						<h:outputText value="#{item.problemSources}" />
					</p:column>
					<p:column headerText="创建时间" style="text-align:center;" width="10">
						<h:outputText value="#{item.createTime}">
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />
						</h:outputText>
					</p:column>
					<p:column headerText="创建人员" style="text-align:center;" width="10">
						<h:outputText value="#{item.createrName}" />
					</p:column>
				</p:dataTable>
			</h:form>

		</div>
	</ui:define>
	<ui:define name="contentend">
		<script type="text/javascript" src="/resources/js/mymodal.js" />
		<script src="/resources/js/tables/singleScrollTable.js" />
		<script>
			function closeAndSave() {
				var index = parent.layer.getFrameIndex(window.name);
				var descData = document.getElementById("headForm:selectedJson").value;
				if (parent.dialogReturn) {
					parent.dialogReturn(index, descData);
				}
				parent.layer.close(index);
			}
		</script>
	</ui:define>
</ui:composition>